package com.zl.credit.util;

import com.zl.credit.entity.CreditProgress;
import com.zl.credit.service.AdminUserUpdate;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
@Component
public class UserUpdaterChain {

    private int position=0;
    // 持有所有的Updater 的实例
        
     List<AdminUserUpdate> updaters;
    public  UserUpdaterChain(List<AdminUserUpdate> updaters) {
        this.updaters = updaters;
    }



    // 触发链的执行
    public void doChain(CreditProgress creditProgressc, int decision ,int power){
        //判断是否已经调完Updater
        if(position<updaters.size()){
            //获取一个责任
            AdminUserUpdate userUpdate=   updaters.get(position);
            position+=1; //调的位置每调一次加一
            //往下传
            userUpdate.update(creditProgressc, decision , power,this);
        }
    }
}
